home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Musique / Quod Libet / quodlibet-3.3.0-installer.exe / bin / quodlibet / qltk / unity.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2014-12-31  |  2KB  |  71 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.7)
  3.  
  4. '''Everything related to Ubuntu Unity integration (quicklist..)
  5.  
  6. See the MPRIS plugin for sound menu integration.
  7. '''
  8. import gi
  9. from quodlibet.util import gi_require_versions
  10. is_unity = True
  11.  
  12. try:
  13.     gi.require_version('Dbusmenu', '0.4')
  14.     from gi.repository import Dbusmenu
  15. except (ValueError, ImportError):
  16.     is_unity = False
  17.  
  18.  
  19. try:
  20.     gi_require_versions('Unity', [
  21.         '7.0',
  22.         '6.0',
  23.         '5.0'])
  24.     from gi.repository import Unity
  25. except (ValueError, ImportError):
  26.     is_unity = False
  27.  
  28.  
  29. def init(desktop_id, player):
  30.     """Set up unity integration.
  31.  
  32.     * desktop_id: e.g. 'quodlibet.desktop'
  33.     * player: BasePlayer()
  34.  
  35.     http://developer.ubuntu.com/api/devel/ubuntu-12.04/c/Unity-5.0.html
  36.     http://developer.ubuntu.com/api/devel/ubuntu-13.10/c/Unity-7.0.html
  37.     """
  38.     if not is_unity:
  39.         return None
  40.     launcher = None.LauncherEntry.get_for_desktop_id(desktop_id)
  41.     main = Dbusmenu.Menuitem.new()
  42.     play_pause = Dbusmenu.Menuitem.new()
  43.     play_pause.property_set(Dbusmenu.MENUITEM_PROP_LABEL, _('Play/Pause'))
  44.     play_pause.property_set_bool(Dbusmenu.MENUITEM_PROP_VISIBLE, True)
  45.     main.child_append(play_pause)
  46.     
  47.     def play_pause_cb(item, timestamp):
  48.         pass
  49.  
  50.     play_pause.connect('item-activated', play_pause_cb)
  51.     next_ = Dbusmenu.Menuitem.new()
  52.     next_.property_set(Dbusmenu.MENUITEM_PROP_LABEL, _('Next'))
  53.     next_.property_set_bool(Dbusmenu.MENUITEM_PROP_VISIBLE, True)
  54.     main.child_append(next_)
  55.     
  56.     def next_cb(item, timestamp):
  57.         player.next()
  58.  
  59.     next_.connect('item-activated', next_cb)
  60.     prev = Dbusmenu.Menuitem.new()
  61.     prev.property_set(Dbusmenu.MENUITEM_PROP_LABEL, _('Previous'))
  62.     prev.property_set_bool(Dbusmenu.MENUITEM_PROP_VISIBLE, True)
  63.     main.child_append(prev)
  64.     
  65.     def prev_cb(item, timestamp):
  66.         player.previous()
  67.  
  68.     prev.connect('item-activated', prev_cb)
  69.     launcher.set_property('quicklist', main)
  70.  
  71.